from lib.sensors.ssd1306.oled import OLED
from lib.config.index import sensor_config
from utils import device
import time

config = sensor_config.get_sensor("ssd1306")
scl = config["scl"]
sda = config["sda"]
width = config["width"]
height = config["height"]

device.running_ticks_us("1")
_oled = OLED(scl, sda, width, height)
device.running_ticks_us("2")


def show_oled_values():
    global _oled
    _oled.text("123456", 0, 0)
    _oled.show()


def show_many_texts():
    global _oled
    texts = ["12345", "hello world", "abcd,1,2,", "36.1C", "000", "26.1C"]
    for text in texts:
        time.sleep(0.2)
        _oled.clear()
        _oled.text(text, 0, 0)
        _oled.show()


device.running_ticks_us("3")
show_oled_values()
device.running_ticks_us("4")
show_many_texts()
device.running_ticks_us("5")
